package parse

import (
	"io/ioutil"
	"fmt"
	"github.com/nofuck/reports/utils"
)

func ScanDir(path string) ([] string, error) {
	fileList := make([]string,0)
	files, err := ioutil.ReadDir(path);
	if err != nil {
		fmt.Println("scan path fail,", err)
		return nil, err
	}
	for _, file := range files {
		if file == nil {
			continue
		}
		if file.IsDir() {
			continue
		}
		fileList = append(fileList, file.Name())
	}
	if fileList == nil {
		err := &utils.CustomerError{"file list is empty"}
		return nil, err
	}
	return fileList, nil
}
